package edu.gwu.computerarchitecture.operation.execute;

import edu.gwu.computerarchitecture.alu.ALU;
import edu.gwu.computerarchitecture.cpu.CPUUnits;
import edu.gwu.computerarchitecture.entity.Register;
import edu.gwu.computerarchitecture.operation.Instruction;

/**
 * 
 * implement the execution of CNVRT instruction
 *
 * <p>detailed comment
 * @author Erzheng Dai 2013年12月6日
 * @see Execute
 * @since 1.0
 * @version 1.0
 */
public class ExecuteCNVRT extends Execute
{
    public ExecuteCNVRT(CPUUnits units, Instruction instr)
    {
        super(units, instr);
        // TODO Auto-generated constructor stub
    }
    /**
     * 
     * implement the CNVRT
     * 
     * @see edu.gwu.computerarchitecture.operation.execute.Execute#execute()
     */
    public void execute(){
        calculateEA();   
        if(instruction.rsr1 == 0){
        	cpuunits.r0.setRegister(cpuunits.mdr.getRegister());
        }
        else if(instruction.rsr1 == 1){
        	cpuunits.fr0.setRegister(Float.floatToIntBits((float)cpuunits.mdr.getRegister().getWord()));
        }
    }
}